<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片列表</title>
    <link rel="stylesheet" href="{{ url_for('static',filename='css/bootstrap.min.css') }}">
    <link rel="stylesheet" href="{{ url_for('static',filename='css/baguetteBox.min.css') }}">
    {#    <link rel="stylesheet" href="{{ url_for('static',filename='css/fluid-gallery.css') }}">#}
    <link rel="stylesheet" href="{{ url_for('static',filename='css/gallery-grid.css') }}">

    <script src="{{ url_for('static',filename='jquery.min.js') }}"></script>
    <script src="{{ url_for('static',filename='socket.io.min.js') }}"></script>

    <style>
        .jq22-demo {
            text-align: center;
            margin-top: 30px;
        }

        .jq22-demo a {
            padding-left: 20px;
            padding-right: 20px;
        }
    </style>
</head>
<body>
<div class="htmleaf-container">
    <div class="container gallery-container">

        <div class="tz-gallery">
            <div class="row">
                <div class="col-sm-6 col-md-4">
                    <a class="lightbox" href="">
                        <img id="currentimage" src="{{ url_for('static',filename='images/park.jpg') }}"
                             alt="take images">
                    </a>
                </div>
                <div>
                    <button id="takepic">拍照</button>
                </div>
            </div>
            <div class="row">
                {% for image in images %}
                    <div class="col-sm-6 col-md-4">
                        <a class="lightbox" href="{{ image }}">
                            <img src="{{ image }}" alt="{{ image }}">
                        </a>
                    </div>
                {% endfor %}
            </div>
        </div>

    </div>

</div>

<script type="text/javascript" src="{{ url_for('static',filename='js/baguetteBox.min.js') }}"></script>
<script type="text/javascript">
        $(document).ready(function () {

            var socket = io.connect('http://' + document.domain + ':' + location.port);

            socket.on('connect', function () {
                socket.emit('check', {data: 'User Connected'})
            });

            socket.on('image', function (msg) {
                const image_element1 = document.getElementById('currentimage');
                image_element1.src = "data:image/jpeg;base64," + msg;
            });

            $("#takepic").bind("click", function () {
                socket.emit('takephoto', {data: 'User take photos'});
            });

        })
    </script>

<script type="text/javascript">
    baguetteBox.run('.tz-gallery');
</script>
</body>
</html>